package com.example.myapplication.api;


import com.example.myapplication.model.bean.DownListBean;
import com.example.myapplication.model.bean.GirlData;
import com.example.myapplication.model.bean.HttpResult;
import com.example.myapplication.model.bean.ImageBean;
import com.example.myapplication.model.bean.NewsDetail;
import com.example.myapplication.model.bean.NewsSummary;
import com.example.myapplication.model.bean.VideoData;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.Streaming;
import retrofit2.http.Url;

/**
 * Created by yin97 on 2017/4/13.
 */

public interface ApiServices {
    String HOST = "http://c.m.163.com/";
    String HOST_UPLOAD="http://api.nohttp.net/";

    @Multipart
    @POST("uploadhead.ssm")
    Observable<HttpResult<ImageBean>> getUpload(@Part("user_name") RequestBody user_name, @Part MultipartBody.Part file);


    @Multipart
    @POST("uploadheads.ssm")
    Observable<HttpResult<ImageBean>> getUploads(@Part("user_name") RequestBody user_name, @Part List<MultipartBody.Part> files);

//    @POST("Ysz/yishengzu")
//    Observable<HttpResult<DataBean>> getinitview();
//
////    Observable<>
//    @Multipart
//    @POST("Login/uploadface")
//    Call<HttpResult<ImgBean>> uploadHead(@PartMap Map<String, String> options,
//                                         @PartMap ArrayList<MultipartBody.Part> externalFileParameters);
//    @Multipart
//    @POST("Login/uploadface")
//    Call<HttpResult<ImgBean>> upLoadImage(@Part("user_id") RequestBody uid, @Part MultipartBody.Part file);
//
//    @Multipart
//    @POST("upload")
//    Call<String> uploads(@QueryMap Map<String, String> options,
//                         @PartMap Map<String, RequestBody> externalFileParameters);
//
//    @Multipart
//    @POST("Login/uploadface")
//    Call<String> uploadFileInfo(@QueryMap Map<String, String> options,
//                                            @PartMap Map<String, RequestBody> externalFileParameters) ;


    @GET("nc/article/{postId}/full.html")
    Observable<Map<String, NewsDetail>> getNewDetail(@Path("postId") String postId);

    @GET("nc/article/{type}/{id}/{startPage}-20.html")
    Observable<Map<String, List<NewsSummary>>> getNewsList(
            @Path("type") String type, @Path("id") String id,
            @Path("startPage") int startPage);

    @GET("data/福利/{size}/{page}")
    Observable<GirlData> getPhotoList(
            @Path("size") int size,
            @Path("page") int page);

    @GET("nc/video/list/{type}/n/{startPage}-10.html")
    Observable<Map<String, List<VideoData>>> getVideoList(
            @Path("type") String type,
            @Path("startPage") int startPage);


    /* 获取下载列表 post */
    @POST(ApiConstants.DOWNLOAD_URL)
    Observable<DownListBean> getDownloadList(
            @Query("page") int page,
            @Query("type") int type
    );

    /*断点续传下载接口*/
    @Streaming/*大文件需要加入这个判断，防止下载过程中写入到内存中*/
    @GET
    Observable<ResponseBody> download(@Header("RANGE") String start, @Url String url);
}
